﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Web.UI.WebControls;
using weikebuluo.Model;
using weikebuluo.DAL;
using weikebuluo.Common;
using weikeweixin.web.wechat.api.cs;

namespace weikeweixin.web.admin.wechat
{
    public partial class menulist : weikeweixin.web.admin.cs.adminbase
    {
        w_caidan_dal menudal = new w_caidan_dal();
        JsonOperate JsonOperate = new JsonOperate();
        common apicommon = new common();

        protected void Page_Load(object sender, EventArgs e)
        {
            switch (Request.QueryString["action"])
            {
                case "menulist":
                    list();
                    break;
                case "del":
                    del();
                    break;
                case "fa":
                    menuset();
                    break;

            }
        }

        private void list()
        {
            string where = "";
            if (!string.IsNullOrEmpty(Request.Form["layid"]))
            {
                where = "caidan_layid=" + Request.Form["layid"] + " and wechat_id=" + wechat_id;
            }
            else
            {
                where = "caidan_layid=0 and wechat_id=" + wechat_id;
            }
            DataTable dtmenu = menudal.GetList(where).Tables[0];
            Response.Write(JsonOperate.TableToBasicJson(dtmenu));
            Response.End();
        }
        private void del()
        {
            menudal.Delete(int.Parse(Request.QueryString["id"].Trim()));
        }

        #region 发布菜单
        /// <summary>
        /// 发布菜单
        /// </summary>
        /// <returns></returns>
        public void menuset()
        {
            string result = apicommon.SetMenu(wechat_id);

        }
        #endregion 发布菜单
    }
}